package com.lingyun.common.spring;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * Created by yfwangbing on 1/14/14.
 */
public class ApplicationContextHolder implements ApplicationContextAware {
    private static ApplicationContext a;

    public static ApplicationContext getApplicationContext() {
        return a;
    }


    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        a = applicationContext;
    }

    public static <T> T getBean(Class<T> type) {
        return a.getBean(type);
    }


}
